package fr.umlv.m2.jee.pmlv.persistence.subject;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import fr.umlv.m2.jee.pmlv.persistence.planning.RecordDate;



/**
 * Represents a theme of a subject. It can be for example a TDTP, lesson...
 * It's an abstract class which use the strategy SINGLE_TABLE. The inheritance
 * class are mapped just by one table in the DataBase.With this strategy we can
 * use the "polymorphisme" and requests are most faster. 
 * 
 * @author jenseric
 *
 */
@SuppressWarnings("serial")
@Entity
@Table(name="Theme")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "theme_type", discriminatorType = DiscriminatorType.STRING)
public abstract class AbstractTheme implements Serializable {

	/**The id of the theme.*/
	@Id
	@GeneratedValue
	@Column(name ="theme_id")
	private long id;
	
	/**The name of the theme.*/
	@Column(name ="theme_name")
	private String name;
	
	/**The name of the filename of the theme.*/ 
	@Column(name ="pdf_filename")
	private String pdfFilename;

        /**The name of the filename of the theme.*/
	@Column(name ="html_filename")
	private String htmlFilename;

        /**The state of theme **/
        @Column(name ="published")
	private int published;
	
	/**The year when the theme is used.*/
	@Column(name="theme_year")
	private int year;
	
	/**the subject where we find the theme.*/
	@ManyToOne
	@JoinColumn(name="subject_id")
	private Subject subject;
	
	@OneToOne(mappedBy="theme")
	private RecordDate recordDate;

	/**
	 * Sets the id of the Theme.
	 * @param id the id to set.
	 */
	public void setId(long id) {
		this.id = id;
	}

	/**
	 * Returns the id of the Theme.
	 * @return the id of the Theme.
	 */
	public long getId() {
		return id;
	}
	
	/**
	 * Sets the name of the theme.
	 * @param name te name to set.
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * Returns the name of the theme.
	 * @return the name of the theme.
	 */
	public String getName() {
		return name;
	}
	
	/**
	 * Sets the filename of the theme.
	 * @param filename the filename of the theme.
	 */
	public void setPdfFilename(String pdfFilename) {
		this.pdfFilename = pdfFilename;
	}
	
	/**
	 * Returns the filename of the theme.
	 * @return the filemane of the theme.
	 */
	public String getPdfFileName() {
		return pdfFilename;
	}

        /**
	 * Sets the filename of the theme.
	 * @param filename the filename of the theme.
	 */
	public void setHtmlFilename(String htmlFilename) {
		this.htmlFilename = htmlFilename;
	}

	/**
	 * Returns the filename of the theme.
	 * @return the filemane of the theme.
	 */
	public String getHtmlFileName() {
		return htmlFilename;
	}
	
	/**
	 * Sets the year of the theme.
	 * @param year the year of the theme to set.
	 */
	public void setYear(int year) {
		this.year = year;
	}
	
	/**
	 * Returns the year of the theme.
	 * @return the year of the theme.
	 */
	public int getYear() {
		return year;
	}
	
	/**
	 * Sets the subject concerned by the theme.
	 * @param subject the subject concerned to set.
	 */
	public void setSubject(Subject subject) {
		this.subject = subject;
	}
	
	/**
	 * Returns the subject concerned by the theme.
	 * @return the subject concerned by the theme.
	 */
	public Subject getSubject() {
		return subject;
	}

	public void setRecordDate(RecordDate recordDate) {
		this.recordDate = recordDate;
	}

	public RecordDate getRecordDate() {
		return recordDate;
	}

        public void setPublished(int published) {
		this.published = published;
	}

	public int getPublished() {
		return published;
	}
}
